home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 7449 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  3.9 KB

  1. Path: Belgium.EU.net!box!pahint
  2. From: pahint@eunet.be (Pieter Hintjens)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Universal include fil
  5. Date: 26 Feb 1996 17:42:08 GMT
  6. Organization: EUnet Belgium, Leuven, Belgium
  7. Message-ID: <4gsrdg$hkh@news.Belgium.EU.net>
  8. References: <4grmre$3uu@gail.ripco.com>
  9. NNTP-Posting-Host: box.eunet.be
  10. X-Newsreader: TIN [version 1.2 PL2]
  11.  
  12. Martin Ambuhl (mambuhl@ripco.com) wrote:
  13. : pahint@eunet.be (Pieter Hintjens)
  14. : in <4gnjea$30m@news.Belgium.EU.net> writes:
  15.  
  16. : >I am working on a project to build a 'Universal Include File'.
  17.  
  18. : There is no conditional for the following
  19. : >#include <fcntl.h>
  20. : even though it is clearly _not_ a standard header.
  21. : Since the other 9 headers in this group are standard headers,
  22. : and since fcntl.h is not guaranteed to be present, I suggest
  23. : a test for the implementation.
  24.  
  25. Can you suggest a test?
  26.  
  27. : The failure to include locale.h, iso646.h, wctype.h, and wchar.h is
  28. : perhaps understandable, since many implementations will not have the
  29. : last three (Amendment 1) headers and these 4 are of limited use to many
  30. : programmers.  I am a little suprised that this should be true for you as
  31. : a .be domain programmer.
  32.  
  33. I'll add locale.h.  Hey, I'm a domain .world programmer, I just never
  34. had use for these guys.  Locale.h is useful enough and widespread enough
  35. to get onto the list.
  36.  
  37. : However, I find the failure to include the standard headers assert.h,
  38. : float.h, math.h, setjmp.h, and stddef.h a little hard to understand.
  39.  
  40. Okay, okay, you convinced me.  They're on the list too.
  41.  
  42. : It is not enough to just #include whatever headers are in some
  43. : implementation.  If your code actually uses any of the stuff associated
  44. : with non-standard headers, you better supply some definition of how
  45. : _other_ implementations can see the same code and do the "right" thing.
  46.  
  47. : Since different implementations will have different definitions of the
  48. : non-standard `extensions', you will perhaps find this exercise worse
  49. : than frustrating.
  50.  
  51. I think the only non-ANSI stuff I use is UNIX-type file handling, since
  52. it's necessary for sockets.  Also, it is widespread if not universal.
  53.  
  54. : You are missing many other common systems.  Check the code for one that
  55. : is missing (__GCC__) and you will find many of the useful ones that you
  56. : have omitted.
  57.  
  58. On problem with gcc (not the product, just the symbol) is that it does
  59. not say a lot about the header files or libraries.  For instance, I'm
  60. trying to find a clean way to compile on a Sun with gcc.  Gcc is using
  61. the non-ANSI Sun header files and library.  What use is __GCC__ for any
  62. kind of work then?
  63.  
  64. : >#if (defined (__TURBOC__))         /*  Borland Turbo-C uses this       */
  65. : >#   include <alloc.h>              *    name for its include file      */
  66. : >#else
  67. : >#   include <malloc.h>
  68. : >#endif
  69.  
  70. : The above is a poor idea.  There are several reasons.  One is that
  71. : Borland has long supplied a malloc.h and alloc.h.  Check the contents of
  72. : these.  You will find that Borland's malloc.h includes alloc.h itself.
  73. : Now, if you have included stdlib.h and stddef.h, you will not need
  74. : malloc.h (or alloc.h) for any of NULL, ptrdiff_t, calloc(), free(),
  75. : malloc(), or realloc().
  76.  
  77. Right.  I've been fooled by an old compiler.  Malloc/calloc are going
  78. out.  I think.
  79.  
  80. : If you code has a prayer of portability you should not want -- and with
  81. : adequate care or the right tools you will not need -- any of headcheck,
  82. : heapfillfree, heapcheckfree, coreleft, _memavl() heapchecknode,
  83. : heapwalk,
  84. : or the abominatitions of the far versions [far*(), _f*()], huge versions
  85. : [h*()] or near versions [_n*()] of the various standard and non-standard
  86. : functions here.
  87.  
  88. What're all these things?  Never heard of them.  Hey, portability is
  89. finally the result of persistent porting, no more or less.
  90.  
  91. : Nor will you need the struct [far]heapinfo.
  92.  
  93. Whatdyasay?
  94.  
  95. : So just
  96. :     #include <stdlib.h>
  97. :     #include <stddef.h>
  98.  
  99. : And forget the malicious jokes <malloc.h> and <alloc.h>.
  100.  
  101. Thanks, Martin, for the useful comments.
  102.  
  103. --
  104. Pieter A. Hintjens
  105.